From fcef7e23538b0e0a88dec48b2efc6b312ab82452 Mon Sep 17 00:00:00 2001 From: Ben Wiederhake Date: Fri, 24 Mar 2017 09:28:35 +0100 Subject: [PATCH] Adapt binaries to new cargo_compile API Closes #3112. --- src/bin/bench.rs | 16 ++++++++++++---- src/bin/build.rs | 18 +++++++++++++----- src/bin/check.rs | 18 +++++++++++++----- src/bin/doc.rs | 10 ++++++---- src/bin/install.rs | 15 +++++++++++---- src/bin/run.rs | 9 +++++---- src/bin/rustc.rs | 18 +++++++++++++----- src/bin/rustdoc.rs | 18 +++++++++++++----- src/bin/test.rs | 25 +++++++++++++++++-------- 9 files changed, 103 insertions(+), 44 deletions(-) diff --git a/src/bin/bench.rs b/src/bin/bench.rs index ffca42abe..ced1cfc39 100644 --- a/src/bin/bench.rs +++ b/src/bin/bench.rs @@ -19,9 +19,13 @@ pub struct Options { flag_message_format: MessageFormat, flag_lib: bool, flag_bin: Vec, + flag_bins: bool, flag_example: Vec, + flag_examples: bool, flag_test: Vec, + flag_tests: bool, flag_bench: Vec, + flag_benches: bool, flag_frozen: bool, flag_locked: bool, arg_args: Vec, @@ -37,9 +41,13 @@ Options: -h, --help Print this message --lib Benchmark only this package's library --bin NAME Benchmark only the specified binary + --bins Benchmark all binaries --example NAME Benchmark only the specified example + --examples Benchmark all examples --test NAME Benchmark only the specified test target + --tests Benchmark all tests --bench NAME Benchmark only the specified bench target + --benches Benchmark all benches --no-run Compile, but don't run benchmarks -p SPEC, --package SPEC ... Package to run benchmarks for -j N, --jobs N Number of parallel jobs, defaults to # of CPUs @@ -92,10 +100,10 @@ pub fn execute(options: Options, config: &Config) -> CliResult { release: true, mode: ops::CompileMode::Bench, filter: ops::CompileFilter::new(options.flag_lib, - &options.flag_bin, - &options.flag_test, - &options.flag_example, - &options.flag_bench), + &options.flag_bin, options.flag_bins, + &options.flag_test, options.flag_tests, + &options.flag_example, options.flag_examples, + &options.flag_bench, options.flag_benches,), message_format: options.flag_message_format, target_rustdoc_args: None, target_rustc_args: None, diff --git a/src/bin/build.rs b/src/bin/build.rs index 13639c1aa..731d563c9 100644 --- a/src/bin/build.rs +++ b/src/bin/build.rs @@ -21,9 +21,13 @@ pub struct Options { flag_release: bool, flag_lib: bool, flag_bin: Vec, + flag_bins: bool, flag_example: Vec, + flag_examples: bool, flag_test: Vec, + flag_tests: bool, flag_bench: Vec, + flag_benches: bool, flag_locked: bool, flag_frozen: bool, flag_all: bool, @@ -42,9 +46,13 @@ Options: -j N, --jobs N Number of parallel jobs, defaults to # of CPUs --lib Build only this package's library --bin NAME Build only the specified binary + --bins Build all binaries --example NAME Build only the specified example + --examples Build all examples --test NAME Build only the specified test target - --bench NAME Build only the specified benchmark target + --tests Build all tests + --bench NAME Build only the specified bench target + --benches Build all benches --release Build artifacts in release mode, with optimizations --features FEATURES Space-separated list of features to also build --all-features Build all available features @@ -99,10 +107,10 @@ pub fn execute(options: Options, config: &Config) -> CliResult { mode: ops::CompileMode::Build, release: options.flag_release, filter: ops::CompileFilter::new(options.flag_lib, - &options.flag_bin, - &options.flag_test, - &options.flag_example, - &options.flag_bench), + &options.flag_bin, options.flag_bins, + &options.flag_test, options.flag_tests, + &options.flag_example, options.flag_examples, + &options.flag_bench, options.flag_benches,), message_format: options.flag_message_format, target_rustdoc_args: None, target_rustc_args: None, diff --git a/src/bin/check.rs b/src/bin/check.rs index e13c68b25..20e7b3bfc 100644 --- a/src/bin/check.rs +++ b/src/bin/check.rs @@ -18,9 +18,13 @@ Options: -j N, --jobs N Number of parallel jobs, defaults to # of CPUs --lib Check only this package's library --bin NAME Check only the specified binary + --bins Check all binaries --example NAME Check only the specified example + --examples Check all examples --test NAME Check only the specified test target - --bench NAME Check only the specified benchmark target + --tests Check all tests + --bench NAME Check only the specified bench target + --benches Check all benches --release Check artifacts in release mode, with optimizations --features FEATURES Space-separated list of features to also check --all-features Check all available features @@ -60,9 +64,13 @@ pub struct Options { flag_release: bool, flag_lib: bool, flag_bin: Vec, + flag_bins: bool, flag_example: Vec, + flag_examples: bool, flag_test: Vec, + flag_tests: bool, flag_bench: Vec, + flag_benches: bool, flag_locked: bool, flag_frozen: bool, flag_all: bool, @@ -98,10 +106,10 @@ pub fn execute(options: Options, config: &Config) -> CliResult { mode: ops::CompileMode::Check, release: options.flag_release, filter: ops::CompileFilter::new(options.flag_lib, - &options.flag_bin, - &options.flag_test, - &options.flag_example, - &options.flag_bench), + &options.flag_bin, options.flag_bins, + &options.flag_test, options.flag_tests, + &options.flag_example, options.flag_examples, + &options.flag_bench, options.flag_benches,), message_format: options.flag_message_format, target_rustdoc_args: None, target_rustc_args: None, diff --git a/src/bin/doc.rs b/src/bin/doc.rs index edbb9b2ec..11e44670f 100644 --- a/src/bin/doc.rs +++ b/src/bin/doc.rs @@ -21,6 +21,7 @@ pub struct Options { flag_package: Vec, flag_lib: bool, flag_bin: Vec, + flag_bins: bool, flag_frozen: bool, flag_locked: bool, flag_all: bool, @@ -41,6 +42,7 @@ Options: -j N, --jobs N Number of parallel jobs, defaults to # of CPUs --lib Document only this package's library --bin NAME Document only the specified binary + --bins Document all binaries --release Build artifacts in release mode, with optimizations --features FEATURES Space-separated list of features to also build --all-features Build all available features @@ -93,10 +95,10 @@ pub fn execute(options: Options, config: &Config) -> CliResult { no_default_features: options.flag_no_default_features, spec: spec, filter: ops::CompileFilter::new(options.flag_lib, - &options.flag_bin, - &empty, - &empty, - &empty), + &options.flag_bin, options.flag_bins, + &empty, false, + &empty, false, + &empty, false), message_format: options.flag_message_format, release: options.flag_release, mode: ops::CompileMode::Doc { diff --git a/src/bin/install.rs b/src/bin/install.rs index 41781a5a5..197dcdd1b 100644 --- a/src/bin/install.rs +++ b/src/bin/install.rs @@ -10,7 +10,9 @@ pub struct Options { flag_no_default_features: bool, flag_debug: bool, flag_bin: Vec, + flag_bins: bool, flag_example: Vec, + flag_examples: bool, flag_verbose: u32, flag_quiet: Option, flag_color: Option, @@ -54,8 +56,10 @@ Build and install options: --all-features Build all available features --no-default-features Do not build the `default` feature --debug Build in debug mode instead of release mode - --bin NAME Only install the binary NAME - --example EXAMPLE Install the example EXAMPLE instead of binaries + --bin NAME Install only the specified binary + --bins Install all binaries + --example NAME Install only the specified example + --examples Install all examples --root DIR Directory to install packages into -v, --verbose ... Use verbose output (-vv very verbose/build.rs output) -q, --quiet Less output printed to stdout @@ -111,8 +115,11 @@ pub fn execute(options: Options, config: &Config) -> CliResult { spec: ops::Packages::Packages(&[]), mode: ops::CompileMode::Build, release: !options.flag_debug, - filter: ops::CompileFilter::new(false, &options.flag_bin, &[], - &options.flag_example, &[]), + filter: ops::CompileFilter::new(false, + &options.flag_bin, options.flag_bins, + &[], false, + &options.flag_example, options.flag_examples, + &[], false), message_format: ops::MessageFormat::Human, target_rustc_args: None, target_rustdoc_args: None, diff --git a/src/bin/run.rs b/src/bin/run.rs index a576cc666..6d66d26ee 100644 --- a/src/bin/run.rs +++ b/src/bin/run.rs @@ -94,10 +94,11 @@ pub fn execute(options: Options, config: &Config) -> CliResult { filter: if examples.is_empty() && bins.is_empty() { ops::CompileFilter::Everything { required_features_filterable: false, } } else { - ops::CompileFilter::Only { - lib: false, tests: &[], benches: &[], - bins: &bins, examples: &examples, - } + ops::CompileFilter::new(false, + &bins, false, + &[], false, + &examples, false, + &[], false) }, message_format: options.flag_message_format, target_rustdoc_args: None, diff --git a/src/bin/rustc.rs b/src/bin/rustc.rs index bff80fece..8805c8f8a 100644 --- a/src/bin/rustc.rs +++ b/src/bin/rustc.rs @@ -22,9 +22,13 @@ pub struct Options { flag_release: bool, flag_lib: bool, flag_bin: Vec, + flag_bins: bool, flag_example: Vec, + flag_examples: bool, flag_test: Vec, + flag_tests: bool, flag_bench: Vec, + flag_benches: bool, flag_profile: Option, flag_frozen: bool, flag_locked: bool, @@ -42,9 +46,13 @@ Options: -j N, --jobs N Number of parallel jobs, defaults to # of CPUs --lib Build only this package's library --bin NAME Build only the specified binary + --bins Build all binaries --example NAME Build only the specified example + --examples Build all examples --test NAME Build only the specified test target - --bench NAME Build only the specified benchmark target + --tests Build all tests + --bench NAME Build only the specified bench target + --benches Build all benches --release Build artifacts in release mode, with optimizations --profile PROFILE Profile to build the selected target for --features FEATURES Features to compile for the package @@ -109,10 +117,10 @@ pub fn execute(options: Options, config: &Config) -> CliResult { mode: mode, release: options.flag_release, filter: ops::CompileFilter::new(options.flag_lib, - &options.flag_bin, - &options.flag_test, - &options.flag_example, - &options.flag_bench), + &options.flag_bin, options.flag_bins, + &options.flag_test, options.flag_tests, + &options.flag_example, options.flag_examples, + &options.flag_bench, options.flag_benches,), message_format: options.flag_message_format, target_rustdoc_args: None, target_rustc_args: options.arg_opts.as_ref().map(|a| &a[..]), diff --git a/src/bin/rustdoc.rs b/src/bin/rustdoc.rs index d82bc3e7e..b6a8e640e 100644 --- a/src/bin/rustdoc.rs +++ b/src/bin/rustdoc.rs @@ -21,9 +21,13 @@ pub struct Options { flag_package: Option, flag_lib: bool, flag_bin: Vec, + flag_bins: bool, flag_example: Vec, + flag_examples: bool, flag_test: Vec, + flag_tests: bool, flag_bench: Vec, + flag_benches: bool, flag_frozen: bool, flag_locked: bool, } @@ -41,9 +45,13 @@ Options: -j N, --jobs N Number of parallel jobs, defaults to # of CPUs --lib Build only this package's library --bin NAME Build only the specified binary + --bins Build all binaries --example NAME Build only the specified example + --examples Build all examples --test NAME Build only the specified test target - --bench NAME Build only the specified benchmark target + --tests Build all tests + --bench NAME Build only the specified bench target + --benches Build all benches --release Build artifacts in release mode, with optimizations --features FEATURES Space-separated list of features to also build --all-features Build all available features @@ -94,10 +102,10 @@ pub fn execute(options: Options, config: &Config) -> CliResult { spec: Packages::Packages(&spec), release: options.flag_release, filter: ops::CompileFilter::new(options.flag_lib, - &options.flag_bin, - &options.flag_test, - &options.flag_example, - &options.flag_bench), + &options.flag_bin, options.flag_bins, + &options.flag_test, options.flag_tests, + &options.flag_example, options.flag_examples, + &options.flag_bench, options.flag_benches,), message_format: options.flag_message_format, mode: ops::CompileMode::Doc { deps: false }, target_rustdoc_args: Some(&options.arg_opts), diff --git a/src/bin/test.rs b/src/bin/test.rs index 65f9b4482..fda62547d 100644 --- a/src/bin/test.rs +++ b/src/bin/test.rs @@ -17,9 +17,13 @@ pub struct Options { flag_lib: bool, flag_doc: bool, flag_bin: Vec, + flag_bins: bool, flag_example: Vec, + flag_examples: bool, flag_test: Vec, + flag_tests: bool, flag_bench: Vec, + flag_benches: bool, flag_verbose: u32, flag_quiet: Option, flag_color: Option, @@ -41,10 +45,14 @@ Options: -h, --help Print this message --lib Test only this package's library --doc Test only this library's documentation - --bin NAME ... Test only the specified binaries + --bin NAME ... Test only the specified binary + --bins Test all binaries --example NAME ... Check that the specified examples compile - --test NAME ... Test only the specified integration test targets - --bench NAME ... Test only the specified benchmark targets + --examples Check that all examples compile + --test NAME ... Test only the specified test target + --tests Test all tests + --bench NAME ... Test only the specified bench target + --benches Test all benches --no-run Compile, but don't run tests -p SPEC, --package SPEC ... Package to run tests for --all Test all packages in the workspace @@ -106,14 +114,15 @@ pub fn execute(options: Options, config: &Config) -> CliResult { let (mode, filter); if options.flag_doc { mode = ops::CompileMode::Doctest; - filter = ops::CompileFilter::new(true, &empty, &empty, &empty, &empty); + filter = ops::CompileFilter::new(true, &empty, false, &empty, false, + &empty, false, &empty, false); } else { mode = ops::CompileMode::Test; filter = ops::CompileFilter::new(options.flag_lib, - &options.flag_bin, - &options.flag_test, - &options.flag_example, - &options.flag_bench); + &options.flag_bin, options.flag_bins, + &options.flag_test, options.flag_tests, + &options.flag_example, options.flag_examples, + &options.flag_bench, options.flag_benches); } let spec = if options.flag_all { -- 2.30.2